package com.plusjun.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyRedissonConfig {
    /**
     * 所有对redis的使用，都通过RedissionClient
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod = "shutdown")
    RedissonClient redisson() throws IOException {
        Config config = new Config();
        // 单节点模式
        config.useSingleServer().setAddress("redis://101.200.53.195:6379");
        // 集群模式
        //config.useClusterServers().addNodeAddress();
        return Redisson.create(config);
    }
}
